package classobject;

class PointCoordinates1 {

	private int x, y;
	public PointCoordinates1(int x, int y) {
		this.x = x;
		this.y = y;
	}
	public int getX() {
		return x;
	}
	public int getY() {
		return y;
	}
	// A better definition, but still not perfect
	
	public boolean equals(Object other) {
		boolean result = false;
		if (other instanceof PointCoordinates1) {
			PointCoordinates1 that = (PointCoordinates1) other;
			result = (this.getX() == that.getX() && this.getY() == that.getY());
		}
		return result;
	}
}

public class EqualsMethod {

	public static void main(String args[]) {
		PointCoordinates1 point1 = new PointCoordinates1(10, 10);
		PointCoordinates1 point2 = new PointCoordinates1(10, 10);
		
		//if (point1 == point2){
		if (point1.equals(point2)){
			System.out.println("Objectos iguales");
		}else{
			System.out.println("Objectos diferentes");
		}
	}
}